#include "pch.h"
#include "Application.h"
#include <cstdint>

int APIENTRY _tWinMain(
   _In_ HINSTANCE _instance,
   _In_opt_ HINSTANCE _prev_instance,
   _In_ LPTSTR _command_line,
   _In_ int _show_command)
{
   UNREFERENCED_PARAMETER(_prev_instance);
   UNREFERENCED_PARAMETER(_command_line);  

   int64_t perf_freq;
   if (!QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER *>(&perf_freq)))
   {
      OutputDebugString(L"high-resoution timer not available"); 
      return FALSE;
   }

   HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);   

   if (SUCCEEDED(CoInitialize(nullptr)))
   {
      dxroids::Application app;
      if (SUCCEEDED(app.Initialize()))
      {
         app.RunMessageLoop();
      }
      dxroids::Particle::Cleanup();         
      CoUninitialize();
   }

   return 0;
}
